SELECT T.* ,
  (SELECT COUNT(0)
  FROM FD_DICTIONARY_TY SDT
  WHERE SDT.PARENT_ID = T.ID
  ) AS CHILD_COUNT,
  (SELECT SDT.NAME
  FROM FD_DICTIONARY_TY SDT
  WHERE SDT.ID = T.PARENT_ID
  ) AS PARENT_NA
FROM FD_DICTIONARY_TY T
WHERE 1 = 1
<#if (PARENT_ID!) == ''>
AND T.PARENT_ID IS NULL
<#else>
AND T.PARENT_ID = :PARENT_ID
</#if>
<#if (ID!) != ''>
AND T.ID       <> :ID
</#if>
ORDER BY T.ORDER_NUM ASC